/**
 * 
 */
package com.shy.portal.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.shy.base.service.impl.BaseServiceImpl;
import com.shy.base.util.ObjectToWhereHql;
import com.shy.base.vo.QueryParamVo;
import com.shy.portal.dao.UserDao;
import com.shy.portal.dao.UserRoleDao;
import com.shy.portal.entity.Menu;
import com.shy.portal.entity.Permission;
import com.shy.portal.entity.Role;
import com.shy.portal.entity.User;
import com.shy.portal.service.UserService;

/**
 * <p>
 * Title: ManagerServiceImpl
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Company:
 * </p>
 * 
 * @author H2013788
 */
@Transactional
@Service("userService")
public class UserServiceImpl extends BaseServiceImpl<User> implements UserService {

    /**
     * userdao
     */
    @Resource
    private UserDao userDao;
    
    @Resource
    private UserRoleDao userRoleDao;

    /**
     * 
     * @param userDao userdao
     * @author H2201965
     * @date 2018/2/6下午3:46:11
     */
    @Resource
    protected void setBaseDao(UserDao userDao) {
        this.baseDao = userDao;
    }

    @Override
    public List<Role> listRoleByUserId(Integer userId) {
        return userDao.listRoleByUserId(userId);
    }

    @Override
    public List<Permission> listPermissionByUserId(Integer userId) {
        return userDao.listPermissionByUserId(userId);
    }

    @Override
    public User getUserByName(String username) {
        return userDao.getUserByName(username);
    }

    @Override
    public List<Menu> listMenuByUserId(Integer userId) {
        return userDao.listMenuByUserId(userId);
    }

    @Override
    public List<User> listUserByParam(User user) {
        if (null != user) {
            String[] like = { "username", "realName" }; 
            QueryParamVo queryParamVo = ObjectToWhereHql.buildWhereHql(user, null,null,like);
            if (null != queryParamVo) {
                return userDao.listUserByParam(queryParamVo.getWhereHql(), queryParamVo.getParams());
            }
        }
        return userDao.findAll();
    }


}
